package com.smh.a10ThreadDemo10;

public class MyThread extends Thread {

    static int ticket = 0;

    @Override
    public synchronized void run() {
        while (true) {
            if (ticket >= 100) {
                break;
            } else {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                ticket++;
                System.out.println(ticket);
            }
        }

    }
}
